<?php
include "include/config.inc.php";
if(!isset($_SESSION['s_activId']))
{
  header('location:checkLogin.php');
}

$partyArray = "";

$selectLoan = "SELECT printId,mobile,mataji,sarkar,lan,fainans,pahoch,address,name,sarnamu,khatanum,tarikh,vajan,vastu,
                      dhirel,sharto,sharto1,sharto2,sharto3,sharto4,sharto5,sharto6,sharto7,sharto8,sharto9,sharto10,
                      sharto11,grahak,vati,sahi
                 FROM print";
$selectLoanRes = mysql_query($selectLoan);
while($loanRow = mysql_fetch_array($selectLoanRes))
{
	$partyArray['printId']       = $loanRow['printId'];
	$partyArray['mobile']     = $loanRow['mobile'];
	$partyArray['mataji']       = $loanRow['mataji'];
	$partyArray['sarkar']       = $loanRow['sarkar'];
	$partyArray['lan']       = $loanRow['lan'];
	$partyArray['fainans']       = $loanRow['fainans'];
	$partyArray['pahoch']       = $loanRow['pahoch'];
	$partyArray['address']       = $loanRow['address'];
	$partyArray['name']       = $loanRow['name'];
	$partyArray['sarnamu']       = $loanRow['sarnamu'];
	$partyArray['khatanum']       = $loanRow['khatanum'];
	$partyArray['tarikh']       = $loanRow['tarikh'];
	$partyArray['vajan']       = $loanRow['vajan'];
	$partyArray['vastu']       = $loanRow['vastu'];
	$partyArray['dhirel']       = $loanRow['dhirel'];
	$partyArray['sharto']       = $loanRow['sharto'];
	$partyArray['sharto1']       = $loanRow['sharto1'];
	$partyArray['sharto2']       = $loanRow['sharto2'];
	$partyArray['sharto3']       = $loanRow['sharto3'];
	$partyArray['sharto4']       = $loanRow['sharto4'];
	$partyArray['sharto5']       = $loanRow['sharto5'];
	$partyArray['sharto6']       = $loanRow['sharto6'];
	$partyArray['sharto7']       = $loanRow['sharto7'];
	$partyArray['sharto8']       = $loanRow['sharto8'];
	$partyArray['sharto9']       = $loanRow['sharto9'];
	$partyArray['sharto10']       = $loanRow['sharto10'];
	$partyArray['sharto11']       = $loanRow['sharto11'];
	$partyArray['grahak']       = $loanRow['grahak'];
	$partyArray['vati']       = $loanRow['vati'];
	$partyArray['sahi']       = $loanRow['sahi'];
}

$loanArrPrint = "";
if(isset($_GET['loanId']))
{
  $selectChallan = "SELECT party.gPartyName,party.address,loan.loanId,DATE_FORMAT(loan.loanDate ,'%d-%m-%Y') AS loanDate,
                           loan.weight,item.itemName,loan.loanAmount,loan.loanVarNo
                      FROM loan
                 LEFT JOIN party ON party.partyId = loan.partyId
                 LEFT JOIN item ON item.itemId = loan.itemId
                     WHERE loan.loanId = ".$_GET['loanId'];
  $selectChallanRes = mysql_query($selectChallan);
  while($selectRow  = mysql_fetch_array($selectChallanRes))
  {                                             
    $loanArrPrint['loanId']     = $selectRow['loanId'];
    $loanArrPrint['partyName']  = $selectRow['gPartyName'];
    $loanArrPrint['address']    = $selectRow['address'];
    $loanArrPrint['loanDate']   = $selectRow['loanDate'];
    $loanArrPrint['weight']     = $selectRow['weight'];
    $loanArrPrint['itemName']   = $selectRow['itemName'];
    $loanArrPrint['loanAmount'] = $selectRow['loanAmount'];
    $loanArrPrint['loanVarNo']  = $selectRow['loanVarNo'];
  }
}
include("bottom.php");
$smarty->assign('partyArray',$partyArray);  
$smarty->assign('loanArrPrint',$loanArrPrint);  
$smarty->display('billListSimple2.tpl');  
?>